﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace App.Views.CheckoutService
{
    //打印公司收入报表
    public partial class PrintFeeReport : System.Web.Mvc.ViewPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Views/CheckoutService/rptMonthFees.rdlc");
                ReportDataSource datasource = new ReportDataSource();
                datasource.Name = "dsMonthFees";
                string t = Request.QueryString["t"];
                string tm = Request.QueryString["tm"];
                datasource.Value = App.Models.ReportClass.GetServiceDetailByMonth(tm,t);

                ReportParameter[] parameters = new ReportParameter[3];
                string y = tm.Substring(0, 4);
                string m = "XX";
                string d = "XX";
                if (t == "2") m = tm.Substring(5, 2);
                else if (t == "3") {
                    m = tm.Substring(5, 2);
                    d = tm.Substring(8, 2);
                }
                parameters[0] = new ReportParameter("reportyear",y);
                parameters[1] = new ReportParameter("reportmonth", m);
                parameters[2] = new ReportParameter("reportday", d);
                ReportViewer1.LocalReport.SetParameters(parameters);
                ReportViewer1.LocalReport.DataSources.Add(datasource);
            } 
        }
    }
}